package com.ruoyi.web.controller.services;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.services.domain.RepairOnline;
import com.ruoyi.services.service.IRepairOnlineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线报修Controller
 * 
 * @author ruoyi
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/services/repairOnline")
public class RepairOnlineController extends BaseController
{
    @Autowired
    private IRepairOnlineService repairOnlineService;

    /**
     * 查询在线报修列表
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairOnline repairOnline)
    {
        startPage();
        List<RepairOnline> list = repairOnlineService.selectRepairOnlineList(repairOnline);
        return getDataTable(list);
    }

    /**
     * 导出在线报修列表
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:export')")
    @Log(title = "在线报修", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RepairOnline repairOnline)
    {
        List<RepairOnline> list = repairOnlineService.selectRepairOnlineList(repairOnline);
        ExcelUtil<RepairOnline> util = new ExcelUtil<RepairOnline>(RepairOnline.class);
        util.exportExcel(response, list, "在线报修数据");
    }

    /**
     * 获取在线报修详细信息
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(repairOnlineService.selectRepairOnlineById(id));
    }

    /**
     * 新增在线报修
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:add')")
    @Log(title = "在线报修", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairOnline repairOnline)
    {
        return toAjax(repairOnlineService.insertRepairOnline(repairOnline));
    }

    /**
     * 修改在线报修
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:edit')")
    @Log(title = "在线报修", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairOnline repairOnline)
    {
        return toAjax(repairOnlineService.updateRepairOnline(repairOnline));
    }

    /**
     * 删除在线报修
     */
    @PreAuthorize("@ss.hasPermi('services:repairOnline:remove')")
    @Log(title = "在线报修", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(repairOnlineService.deleteRepairOnlineByIds(ids));
    }
}
